<!DOCTYPE html>
<html lang="cn" xmlns:th="http://www.thymeleaf.org">
<head th:include="module/public/include :: mainhead('任务列表')">
</head>
<body>
	<section>
		<div th:replace="module/public/menu"></div>

		<!-- main content start-->
		<div class="main-content">
			<!--body wrapper start-->
			<div class="wrapper">
				<div class="panel panel-default ">
					<div class="panel-heading template-panel-gray">
						<div class="panel-title">任务管理</div>
					</div>
					<!--操作查询-->
					<div class="panel-body">
						<form class="row">
							<div class="container-fluid">
								<div id="params"></div>
								<div class="row">
									<div class="col-xs-12 col-md-10 form-group">
										<div class="btn-toolbar">
											<button type="button" id="create-btn" class="btn  btn-primary template-btn-green" onclick="add()">新增</button>
											<button type="button" id="create-btn" class="btn  btn-primary template-btn-green" onclick="del()">删除</button>
											<button type="button" id="create-btn" class="btn  btn-primary template-btn-green">执行</button>
											<button type="button" id="create-btn" class="btn  btn-primary template-btn-green">关闭</button>
										</div>
									</div>
									<div class="col-xs-12 col-md-2 form-group">
										<div class="btn-toolbar template-search-btn ">
											<button class="btn  btn-primary template-btn-green " type="button" onclick="search()">
												<i class="fa fa-search"></i>
												查询
											</button>
										</div>
									</div>
								</div>
							</div>
						</form>
					</div>
				</div>
				<section class="panel">
					<div class="panel-body row">
						<div class="adv-table">
							<table id="gird"></table>
							<div id="paginator"></div>
						</div>
					</div>
				</section>
			</div>
		</div>
	</section>
	<script type="text/javascript">
	$("#gird").module("grid",{
		 url: "[[@{/jobInfo/list}]]",
		 mtype: "get",
		 colModel: [
	            { name: 'id', hidden:true},
	            { sortable:false, label : '名称',name :'name',align:'center',formatter:edit},
	            { sortable:false, label : 'key',name :'key',align:'center'},
	            { sortable:false, label : '分组',name :'group',align:'center'},
	            { sortable:false, label : '服务名',name :'msName',align:'center'},
	            { sortable:false, label : '类名',name :'beanClass',align:'center'},
	            { sortable:false, label : '方法名',name :'method',align:'center'},
	            { sortable:false, label : '状态',name: 'status',align:'center'},
	            { sortable:false, label : '类型',name :'type',align:'center'},
	            { sortable:false, label : '创建人',name: 'createUser',align:'center'},
	            { sortable:false, label : '创建时间',name: 'createTime',align:'center'}
	        ]
	});
	
	function edit(cellval, options, row){
		if(cellval != null){
			return '<a href="[[@{/view/module/page/jobEdit.html?id=}]]'+row.id+'">'+cellval+'</a>';
			
// 			return "<a href='[[@{/view/module/page/jobEdit.html?id=}]]"+row.id+"' target='_self'>"+val+"</a>";
		}
	}
	
	$("#params").module("query",{
		forms:[
			{key:"name",name:"名称"},
			{key:"group",name:"分组"},
			{key:"status",name:"状态"},
			{key:"group",name:"服务名称"}
		],
		drawtype:"replace",
		row:true,
		rows:4
	});
	
	function add(){
		window.location.href = "[[@{/view/module/page/jobEdit.html}]]";
	}
	
	function del(){
		var id_arr =  $("#gird").jqGrid('getGridParam','selarrrow');
		
		if(id_arr.length){
			$.ajax({
				url:"[[@{/jobInfo/del}]]",
				type:'POST',
				dataType:'json',
				data:{ids:id_arr.toString()},
				success:function(result){
					if(result.status=='1.3'){
						alertModal("操作成功!");
						$('#gird').jqGrid('setGridParam', {
							dataType : 'json',
							page : 1
						}).trigger('reloadGrid');
					}
				}
			})
		}else{
			alertModal("请选择数据!");
		}
	}
	</script>
</body>
</html>